<?php

namespace app\common\model;

use think\Model;
use think\Db;
use think\Config;

class QbankAssociation extends Model {

    // 指定表名,不含前缀
    protected $name = 'qbank_association';

    /**
     * 根据参数获取列表
     * @param array|null $arg
     * @param string $field
     * @param int $argor
     * @return array|bool|false|\PDOStatement|string|\think\Collection
     */
    public function getListByArg(array $arg=null,$field='*',$argor=1){
        if (!is_array($arg))return false;
        $arg = $this->where($arg)->where($argor)->field($field)->select();
        return $arg;
    }
    public function getListByArgOne(array $arg=null,$field='*'){
        if (!is_array($arg))return false;
        $arg = $this->where($arg)->field($field)->find();
        return $arg;
    }
	
	public function getListByArgAss($plaformid=0,$type=0){
		$qb_id = array();
        $arg = $this->where(['plaformid'=>$plaformid,'marks'=>0]);
		if($type==1){
			$arg = $arg->where('status=0');
		} else if($type==2){
			$arg = $arg->where('status=1');
		}
		$arg = $arg->field('qb_id')->select();

		foreach($arg as $v){
			$qb_id[] = $v->qb_id;
		}

        return $qb_id;
    }
	
	public function getAdminReg($plaformid,$bankId){
		if(!$plaformid || !$bankId){
				return false;
			
		}
		$qb_id = array();
        $arg = $this->where(['plaformid'=>$plaformid,'qb_id'=>$bankId])->field('qb_id')->find();
	
		if(empty($arg->qb_id)){
			return false;
			
		}
		$result = Db::name('qbank')->field('admin_reg')->where(['id'=>$bankId])->find();
	
        return $result["admin_reg"];
    }

    

}
